<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="com.Dao.ProcDao"%>
<%@page import="com.pojo.Sub"%>
    <%@page import="com.pojo.User"%>
    <%@page import="com.Dao.UserDao"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sendcards</title>
<link rel="stylesheet" type="text/css"
	href="../HI-files/css/candy-box.css">
<link rel="stylesheet" type="text/css"
	href="../HI-files/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css"
	href="../HI-files/css/animate.min.css">
<link rel="stylesheet" type="text/css"
	href="../HI-files/css/jquery.skippr.css">
<link rel="stylesheet" type="text/css" href="../HI-files/css/style.css">
<link rel="stylesheet" type="text/css" href="css/send.css">
<script type="text/javascript" charset="utf-8"
	src="../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="../ueditor/ueditor.all.min.js"> </script>
	<script src="js/jquery.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载
失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8"
	src="./ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
	<%@ include file="../include/header.jsp"%>
	<div class="sendcontent">
	<h3>这一刻想发表</h3>
		<div>
			<select name="selectAge" id="selectAge">
				<option value="旅游">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;旅游</option>
				<option value="娱乐">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;娱乐</option>
				<option value="体育">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;体育</option>
				<option value="美食">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;美食</option>
				<option value="美景">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;美景</option>

			</select>
		</div>
		<br />
		<div>
			<input type="text" id="bt" placeholder="标&nbsp;题&nbsp;:">
		</div>
		<br />
		<div>
			<script id="editor" type="text/plain"
				style="width:1024px;height:500px;"></script>
		</div>
		<br/>
		<div id="btns">
			<div>
				<button onclick="getClk2()">发表</button>

			</div>
		</div>
	</div>
	<script>
	
	function getClk2() {
		var theme=$("#selectAge option:selected").val(); 	
		var title = $(" #bt").val() ;
		var datax = UE.getEditor('editor').getContent() ;
		var neirong = UE.getEditor('editor').hasContents();
		var Uid = <%= ((User)session.getAttribute("user")).getUid()%> ;
		if (neirong){
			$.post("${pageContext.request.contextPath }/procCtrj",
					{theme:theme,title:title,uid:Uid,contant:datax},
			    	function(data){

						var count =0
					for(var i=0;i<data.length;i++){
						var x = JSON.stringify(data[i]);
							if(x == "null"){
								count= i;
								break;
							}
						}	
			        },"json"
			);
			}else{
				alert('请输入内容');
			};
		};
	
	
	
	//实例化编辑器
					    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
					    var ue = UE.getEditor('editor');
					   
					
					    function isFocus(e){
					        alert(UE.getEditor('editor').isFocus());
					        UE.dom.domUtils.preventDefault(e)
					    }
					    function setblur(e){
					        UE.getEditor('editor').blur();
					        UE.dom.domUtils.preventDefault(e)
					    }
					    function insertHtml() {
					        var value = prompt('插入html代码', '');
					        UE.getEditor('editor').execCommand('insertHtml', value)
					    }
					    function createEditor() {
					        enableBtn();
					        UE.getEditor('editor');
					    }
					    function getAllHtml() {
					        alert(UE.getEditor('editor').getAllHtml())
					    }
					    function getContent() {
					        var arr = [];
					        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
					        arr.push("内容为：");
					        arr.push(UE.getEditor('editor').getContent());
					        alert(arr.join("\n"));
					    }
					    function getPlainTxt() {
					        var arr = [];
					        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
					        arr.push("内容为：");
					        arr.push(UE.getEditor('editor').getPlainTxt());
					        alert(arr.join('\n'))
					    }
					    function setContent(isAppendTo) {
					        var arr = [];
					        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
					        UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
					        alert(arr.join("\n"));
					    }
					    function setDisabled() {
					        UE.getEditor('editor').setDisabled('fullscreen');
					        disableBtn("enable");
					    }
					
					    function setEnabled() {
					        UE.getEditor('editor').setEnabled();
					        enableBtn();
					    }
					
					    function getText() {
					        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
					        var range = UE.getEditor('editor').selection.getRange();
					        range.select();
					        var txt = UE.getEditor('editor').selection.getText();
					        alert(txt)
					    }
					
					    function getContentTxt() {
					        var arr = [];
					        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
					        arr.push("编辑器的纯文本内容为：");
					        arr.push(UE.getEditor('editor').getContentTxt());
					        alert(arr.join("\n"));
					    }
					    function hasContent() {
					        var arr = [];
					        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
					        arr.push("判断结果为：");
					        arr.push(UE.getEditor('editor').hasContents());
					        alert(arr.join("\n"));
					    }
					    function setFocus() {
					        UE.getEditor('editor').focus();
					    }
					    function deleteEditor() {
					        disableBtn();
					        UE.getEditor('editor').destroy();
					    }
					    function disableBtn(str) {
					        var div = document.getElementById('btns');
					        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
					        for (var i = 0, btn; btn = btns[i++];) {
					            if (btn.id == str) {
					                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
					            } else {
					                btn.setAttribute("disabled", "true");
					            }
					        }
					    }
					    function enableBtn() {
					        var div = document.getElementById('btns');
					        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
					        for (var i = 0, btn; btn = btns[i++];) {
					            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
					        }
					    }
					
					    function getLocalData () {
					        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
					    }
					
					    function clearLocalData () {
					        UE.getEditor('editor').execCommand( "clearlocaldata" );
					        alert("已清空草稿箱")
					    }
					</script>
</body>
</html>